from PyQt5.QtCore import QObject, pyqtProperty as Property, pyqtSignal as Signal, QPointF
from PyQt5.QtGui import QColor

from PyQt5.QtQuick import (QQuickItem, QSGFlatColorMaterial,
                             QSGGeometry, QSGGeometryNode, QSGNode)
# from PyQt5.QtQml import QmlElement

# QML_IMPORT_NAME = "BppTable"
# QML_IMPORT_MAJOR_VERSION = 1
# @QmlElement
class BTHeading(QObject):
    def __init__(self,parent=None):
        super().__init__(parent)
        self.columnsDef=[]

    def getColWidth(self, columnId):
        if(columnId<0):
            return 100;

        if(not self.columnsDef[columnId].visible):
            return 0;

        return self.columnsDef[columnId].width;


    def clearColumnsDef(self):
        # for(auto col: columnsDef){
        #     delete col;
        # }
        self.columnsDef=[]


    def addColumnDef(self):
        newCol=len(self.columnsDef)
        self.columnsDef.append(TableColumn() )
        return newCol;

    def setColumnDef(self, columnId, withDefaults, colDef):
        self.columnsDef[columnId].modify(colDef, withDefaults)

    def getColumnDef(self, columnId):
        return self.columnsDef[columnId]

    def sizeColumnsDef(self):
        return len(self.columnsDef)

